package com.example.websocket.executor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SingleThreadPool {
    public static void main(String[] args) {
        ExecutorService service = Executors.newSingleThreadExecutor();
        for (int i = 0; i < 10; i++) {
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程名：" + Thread.currentThread().getName());
                }
            });
        }
    }
    // 1、复用线程。
    // 2、单线程的线程池提供了任务队列和拒绝策略（当任务队列满了之后(Integer.MAX_VALUE)，新来的任务就会拒绝策略）。
}
